package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.api.db.TestQuestionApi;
import com.tanhua.dubbo.api.mapper.TestQuestionMapper;
import com.tanhua.model.db.QuestionTest;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 提交问卷问题实现类
 */
@DubboService
public class TestQuestionApiImpl implements TestQuestionApi {


    @Autowired
    private TestQuestionMapper testSoulMapper;

    /**
     * 根据问题id查询问题对象
     *
     * @param questionId
     * @return
     */
    @Override
    public QuestionTest findById(Integer questionId) {
        return testSoulMapper.selectById(questionId);
    }

    @Override
    public List<QuestionTest> findByQuestionnaireId(Integer questionnaireId) {
        QueryWrapper<QuestionTest> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("questionnaire_id", questionnaireId);
        return testSoulMapper.selectList(queryWrapper);
    }

}
